﻿    <%@ Page Language="C#" MasterPageFile="~/Shared/EOS.master" AutoEventWireup="True" EnableEventValidation="true"
    Inherits="EOSCRM.Web.Forms.DongHo.NhapDongHoKhachHang" CodeBehind="NhapDongHoKhachHang.aspx.cs" %>
<%@ Import Namespace="EOSCRM.Util" %>
<%@ Register Assembly="EOSCRM.Controls" Namespace="EOSCRM.Controls" TagPrefix="eoscrm" %>
<%@ Register src="../../UserControls/KhachHangFilterPanel.ascx" tagname="KhachHangFilterPanel" tagprefix="bwaco" %>

<asp:Content ID="head" ContentPlaceHolderID="headCPH" runat="server">

    <script type="text/javascript">
        $(document).ready(function() {
            $("#divDuongPho").dialog({
                autoOpen: false,
                modal: true,
                minHeight: 100,
                height: 'auto',
                width: 'auto',
                resizable: false,
                open: function(event, ui) {
                    $(this).parent().appendTo("#divDuongPhoDlgContainer");
                }
            });
        });
            function updateThayDongHo(idkh,  txtNgayThayId,txtNgayHetHanId,txtMaDHId, ddlMaLoaiDHId,Manv) {
		    openWaitingDialog();
		    unblockWaitingDialog();
		    var ngaythay = document.getElementById(txtNgayThayId).value;
		    var ngayhethan = document.getElementById(txtNgayHetHanId).value;
		    var madh = document.getElementById(txtMaDHId).value;
		    var f = document.getElementById(ddlMaLoaiDHId);
		    var maldh = f.options[f.selectedIndex].value;
		    var msg = EOSCRM.Web.Common.AjaxCRM.UpdateThayDongHo(idkh, ngaythay, ngayhethan, madh, maldh, Manv);
		    
		    if(msg.value != "<%= DELIMITER.Passed %>" && msg.value != "<%= DELIMITER.Failed %>") {
		    
		        var idArr = msg.value.split("<%= DELIMITER.Delimiter %>");

		        if (idArr.length == 4) {
		            /*
                    document.getElementById(txtNgayThay).value = idArr[0];
                    document.getElementById(txtNgayHetHan).value = idArr[1];
                    document.getElementById(txtMaDH).value = idArr[2];
                    document.getElementById(ddlMaLoaiDH).value = idArr[3];*/
		        }
		    }
		    closeWaitingDialog();
		}
    </script>
</asp:Content>
<asp:Content ID="content" ContentPlaceHolderID="mainCPH" runat="server">
    <bwaco:KhachHangFilterPanel ID="filterPanel" runat="server" />    
    <asp:UpdatePanel ID="upnlCustomers" UpdateMode="Conditional" runat="server">
        <ContentTemplate>
            <br />
            <div class="crmcontainer">
            <table class="crmtable" >
            <tr>
                <td class="crmcell">
                    <asp:Button ID="btnSave" CssClass="save" runat="server" 
                        onclick="btnSave_Click1" />
                </td>
            </tr>
           </table>
                <eoscrm:Grid 
                    ID="gvKhachHang" runat="server" UseCustomPager="true" PageSize="200"
                    onrowdatabound="gvKhachHang_RowDataBound">
                    <PagerSettings FirstPageText="khách hàng" PageButtonCount="2" />
                    <Columns>
                        <asp:TemplateField HeaderStyle-Width="10px" HeaderText="STT">
                            <ItemTemplate>
                                <%# Container.DataItemIndex + 1%>
                            </ItemTemplate>
                        </asp:TemplateField>
                        <asp:TemplateField HeaderStyle-Width="10%" HeaderText="Mã khách hàng">
                            <ItemTemplate>
                                <%# Eval("MADP").ToString()+Eval("DUONGPHU").ToString()+Eval("MADB").ToString() %>
                            </ItemTemplate>
                            <ItemStyle Font-Bold="True" />
                        </asp:TemplateField>                
                        <asp:BoundField HeaderStyle-Width="25%" HeaderText="Tên khách hàng" DataField="TENKH" />
                        <asp:TemplateField HeaderStyle-Width="25%" HeaderText="Địa chỉ">
                            <ItemTemplate>
                                <%# Eval("SONHA") != null && Eval("SONHA").ToString() != "" ? Eval("SONHA") + ", " : "" %>
                                <%# Eval("DUONGPHO.TENDP")%>, 
                                <%# Eval("PHUONG") != null ? Eval("PHUONG.TENPHUONG") : "" %>
                            </ItemTemplate>
                        </asp:TemplateField>    
                        <asp:TemplateField HeaderStyle-Width="100" HeaderText="Số Serial">
                            <ItemTemplate>
                                <asp:TextBox ID="txtMaDH" Text='<%# Bind("MADH")%>' Width="90%" runat="server"></asp:TextBox>
                            </ItemTemplate>
                        </asp:TemplateField> 
                        <asp:TemplateField HeaderStyle-Width="100" HeaderText="Ngày thay">
                            <ItemTemplate>
                                <asp:TextBox ID="txtNgayThay"  Text='<%# Bind("NGAYHT")%>'  Width="90%" runat="server" tag="datevn" />
                            </ItemTemplate>
                        </asp:TemplateField>
                        <asp:TemplateField HeaderStyle-Width="100" HeaderText="Ngày hết hạn">
                            <ItemTemplate>
                                <asp:TextBox ID="txtNgayHetHan"  Text='<%# Bind("NGAYHETHANDH")%>'  Width="90%" runat="server" tag="datevn" />
                            </ItemTemplate>
                        </asp:TemplateField>
                        <asp:TemplateField HeaderStyle-Width="150px" HeaderText="Mã Loại ĐH">
                            <ItemTemplate>
                                <asp:DropDownList ID="ddlMaLoaiDH" runat="server"></asp:DropDownList>
                            </ItemTemplate>
                        </asp:TemplateField>
                    </Columns>
                </eoscrm:Grid>   
            </div>
            <br />
                   
        </ContentTemplate>
    </asp:UpdatePanel> 
</asp:Content>
